package com.jinmdz.fmis.api.api.service;

import com.jinmdz.fmis.api.api.model.common.DictTypeData;
import com.jinmdz.fmis.api.api.model.common.TypeCodeData;
import com.jinmdz.fmis.api.base.BaseService;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.dao.ServiceItemDao;
import com.jinmdz.fmis.dao.model.service.ServiceItem;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * ServiceItemService类
 *
 * @author LiCongLu
 * @date 2020-01-20 10:45
 */
@Service("serviceItemService")
public class ServiceItemService extends BaseService {

    @Resource
    private ServiceItemDao serviceItemDao;

    /**
     * 根据业务组编码加载service_item表中服务项目信息
     *
     * @param data 业务组编码
     * @return
     * @author LiCongLu
     * @date 2020-02-12 15:37
     */
    public BaseResult<ArrayList<ServiceItem>> loadServiceItemWithTypeCode(TypeCodeData data) {
        // 查询数据
        ArrayList<ServiceItem> loadItems = serviceItemDao.listServiceItemByBusinessType(data.getTypeCode());

        // 返回响应结果
        return successList(loadItems);
    }

    /**
     * 根据字典编码加载与字典关联的服务项目信息
     *
     * @param data 字典编码数据
     * @return
     * @author LiCongLu
     * @date 2020-02-12 16:27
     */
    public BaseResult<ServiceItem> loadServiceItemWithDicTypeCode(DictTypeData data) {
        // 查询数据
        ServiceItem serviceItem = serviceItemDao.getServiceItemByDictCode(data.getDicType(), data.getTypeCode(), data.getPurpose());

        // 返回响应结果
        return successData(serviceItem);
    }
}
